<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="layout :: common_header(~{::title})">
    <title >发货统计</title>
</head>
<body th:replace="layout :: common_body(~{::div.layui-body})">

<div class="layui-body" style="padding:15px;">
    <style type="text/css">
        .update {
            display: inline-block;
            margin-left: 15px;
            padding: 0 20px;
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            background: #009789;
            color: #fff;
            text-align: center;
            border-radius: 3px;
            cursor: pointer;
        }

        .update i {
            display: inline-block;
            margin-right: 10px;
            vertical-align: middle;
            width: 30px;
            height: 30px;
            background: url();
        }
        .T-box {
            width: 400px;
            padding: 0 20px;
            text-align: left;
        }

        .T-box p {
            position: relative;
            height: 36px;
            line-height: 36px;
            font-size: 14px;
            margin-bottom: 15px;
        }

        .T-box p span {
            display: inline-block;
            padding-right: 15px;
            text-align: right;
            width: 110px;
            line-height: 36px;
            font-size: 14px;
        }

        .T-box p input, .T-box p select {
            width: 250px;
            padding: 0 5px;
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            border: 1px solid #d3d3d3;
            outline: none;
        }

        .T-box p i {
            padding: 0 10px;
            line-height: 36px;
            font-style: normal;
        }

        .T-box p b {
            display: inline-block;
            margin-left: 10px;
            cursor: pointer;
            width: 60px;
            height: 36px;
            line-height: 36px;
            background: #c33;
            color: #fff;
            text-align: center;
            font-size: 13px;
            font-weight: normal;
        }
        .yinc{display: none;}
    </style>

    <fieldset class="layui-elem-field">
        <legend>按条件搜索</legend>
        <div class="layui-field-box">
            <form class="layui-form layui-form-pane1" method="get" action="/fahuo/order_send_daily">
                
                <div class="layui-form-item">
                    
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="shopId" id="shopId">
                                <option value="0" selected>请选择店铺</option>
                                <option  th:each="item: ${shops}" th:text="${item.name}" th:value="${item.id}">等待发货</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="date" th:value="${date}" id="date" autocomplete="off" placeholder="日期" style="width: 200px;" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <input type="text" name="endDate" th:value="${endDate}" id="endDate" autocomplete="off" placeholder="日期" style="width: 200px;" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <button type="submit" class="layui-btn layui-btn-normal">搜索</button>
                        <i>总共：<span style="color: red" th:text="${totalSize}" id="totalSends"></span>件商品</i>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>

    <!-- start dd-wrapper -->
    <link rel="stylesheet" href="/goods/order.css"/>
    <div class="dd-wrapper">
        <table class="dd-table">
            <tr>
                <th>序号</th>
                <th>GoodsId</th>
                <th>编号</th>
                <th width="80px">主图</th>
                <th>商品标题</th>
                
                <th>数量(<span id="quantity"></span>)</th>
                <th>订单金额(<span id="amount"></span>)</th>
                <th>成本</th>
                <th>盈亏(<span style="color: red;" id="yingkuit"></span>)</th>
            </tr>
            <tr th:each="item:${report}">
                <td th:text="${itemStat.index+1}"></td>
               
                <td th:text="${item.goodsId}"></td>
                <td><span  th:text="${item.goodsNumber}"></span></td>
                <td>
                    <div ><img th:src="${item.goodsImg}">
                    </div>
                </td>
                <td><span  th:text="${item.goodsName}"></span></td>
                
                
                <td><span th:text="${item.quantity}" class="quantity"></span></td>
                <!-- <td><span th:text="${#numbers.formatDecimal(item.price * item.quantity ,2,2)}" class="amount"></span></td> -->
                <td><span th:text="${#numbers.formatDecimal(item.itemAmount ,2,2)}" class="amount"></span></td>
                
                <td><span th:text="${#numbers.formatDecimal(item.purPrice ,2,2)}"></span></td>
                <td>
                    <span th:text="${#numbers.formatDecimal(item.itemAmount - item.purPrice,1,2) }" style="color: #ed0119;" class="yingkui">0</span>
                </td>
            </tr>
        </table>
    </div>
    <!-- end dd-wrapper -->
    <div class="layui-box layui-laypage layui-laypage-default pageBox">
        <paging:pager th:value="${pageIndex}" th:rows="${totalSize}" th:size="${pageSize}"/>
    </div>
    <script type="text/template" id="send-goods">
        <div class="T-box">
            <p><span>sku编码</span><input type="text" name="express_code"/></p>
            <p class="T-result"><span>&nbsp;</span><em id="erro"></em></p>
        </div>
    </script>
    <script type="text/javascript" src="/goods/Tips/Tips.min.js"></script>
    <script type="text/javascript">
        var layer;
        var $;
        var windowOpen;
        layui.use(['laydate', 'jquery', 'form', 'layer'], function () {
            var laydate = layui.laydate;
            $ = layui.jquery;
            var form = layui.form;
            layer = layui.layer;
            laydate.render({
                elem: '#date'
                ,type: 'date'
            });
            laydate.render({
                elem: '#endDate'
                ,type: 'date'
            });
            
        
            $(function () {
                $("#shopId").val('[[${shopId}]]');

                form.render('select'); //刷新select选择框渲染

                //计算总盈亏
                var yingkuit = 0.0;
                $(".yingkui").each(function(){
                    yingkuit += parseFloat($(this).text());
                })
                $("#yingkuit").text("￥"+yingkuit.toFixed(2));
                var quantity=0;
                $(".quantity").each(function(){
                    quantity+=parseInt($(this).text());
                })
                $("#quantity").text(quantity);
                $("#totalSends").text(quantity);
                var amount = 0.0;
                $(".amount").each(function(){
                    amount+=parseFloat($(this).text());
                })
                $("#amount").text("￥"+amount.toFixed(2));
            })


        });

    </script>

</div>
</body>
<html>
